<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="用户名"
                    prop="username"
                    :rules="[
      { required: true, message: '用户名不能为空',trigger: 'blur'},
      ]">
        <el-input v-model="form.username"/>
      </el-form-item>
      <el-form-item label="新密码"
                    prop="password"
                    :rules="[
      { required: true, message: '不能为空',trigger: 'blur'},
      ]">
        <el-input type="password" v-model="form.password"/>
      </el-form-item>
      <el-form-item label="确认密码"
                    prop="confirm"
                    :rules="[
      { required: true, message: '不能为空',trigger: 'blur'},
      ]">
        <el-input type="password" v-model="form.confirm"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit('form')">更新</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import jwtDecode from "jwt-decode";
import {getToken} from "@/utils/auth";
import popMessage from "@/utils/popMessage";

export default {
  name:"updatePassword",
  data() {
    return {
      form: {
        username: jwtDecode(getToken()).username,
        userId:jwtDecode(getToken()).userId,
        password:'',
        confirm:''

      }
    }
  },
  methods: {
    onSubmit(formName) {

      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });


    },
  }
}
</script>

<style scoped>
.line{
  text-align: center;
}
</style>

